<?php

class LinhVuc extends Zend_Db_Table_Abstract {

    protected $_name = 'bk_linhvuc';

    function SelectLinhVucList($filtername) {
        global $db;

        $where = " 1=1 ";
        $wherearray = Array();
        if ($filtername != "") {
            $where .= " AND NAME LIKE ?";
            $wherearray[] = '%' . $filtername . '%';
        }

        $sql = "SELECT * FROM bk_linhvuc WHERE $where and ACTIVE=1";

        $r = $db->query($sql, $wherearray);

        return $r->fetchAll();
    }
    
    function SelectLinhVucListFull($filtername) {
        global $db;

        $where = " 1=1 ";
        $wherearray = Array();
        if ($filtername != "") {
            $where .= " AND NAME LIKE ?";
            $wherearray[] = '%' . $filtername . '%';
        }

        $sql = "SELECT * FROM bk_linhvuc WHERE $where";

        $r = $db->query($sql, $wherearray);

        return $r->fetchAll();
    }

    function SelectLinhVucById($id) {
        global $db;
        $where = " 1=1 ";
        $wherearray = Array();
        if ($id != "") {
            $where .= " AND ID_LV = ?";
            $wherearray[] = $id;
        }

        $sql = "SELECT * FROM bk_linhvuc WHERE $where";

        $r = $db->query($sql, $wherearray);

        return $r->fetch();
    }

}
